package com.qqs.socket;

import java.util.List;

import org.apache.log4j.Logger;

import com.qqs.util.ConvertUtil;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
import io.netty.handler.codec.MessageToByteEncoder;

public class ToByteEncoder extends MessageToByteEncoder {
	private static final Logger logger = Logger.getLogger(ToByteEncoder.class);
	private static String olddata="";
	@Override
	protected void encode(ChannelHandlerContext ctx, Object msg, ByteBuf out) throws Exception {
		// TODO Auto-generated method stub
		String str = new String((char[])msg);
		byte data[] = str.getBytes("ISO-8859-1"); 
		logger.info("发送数据："+ConvertUtil.printHexString(data,data.length));
		ctx.write(data);
	}
	

}
